import { mapMutations } from 'vuex'
export default {
  methods: {
    ...mapMutations('material', ['setMaterialInfo']),
    ...mapMutations('programs', ['setShowMaterial']),
    beforeOpen (info = {}) {
      this.setMaterialInfo(info)
      this.$nextTick(() => {
        this.setShowMaterial(true)
      })
    },
    getStyle (path, type) {
      path = path || this.getDefault(type)
      return {
        background: `url(${path}) no-repeat center / 100%`,
        backgroundColor: 'white'
      }
    },
    getDefault (type) {
      if (type === 1) {
        return './static/img/img-video.png'
      } else if (type === 3) {
        return './static/img/img-doc.png'
      } else if (type === 4) {
        return './static/img/img-audio.png'
      }
      return ''
    }
  }
}
